package blogger.client.ui.widgets;

import blogger.client.async.Callback;
import blogger.client.async.services.UserService;
import blogger.client.async.services.UserServiceAsync;
import blogger.client.model.entity.User;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;


/**
 * Created by IntelliJ IDEA.
 * User: mega
 * Date: 24.12.2009
 * Time: 22:30:22
 * To change this template use File | Settings | File Templates.
 */
public class UserView extends Composite{
    private Image image = null;
    private Label login = null;

    public UserView(User u){
        super();
        VerticalPanel panel = new VerticalPanel();
        image = new Image("../images/no_foto.gif");
        login = new Label(u.getLogin());
        panel.add(login);
        panel.add(image);
        this.initWidget(panel);
    }
    public UserView(long user_id){
        super();
        VerticalPanel panel = new VerticalPanel();
        image = new Image("../images/no_foto.gif");
//        login = new Label(u.getLogin());
        UserServiceAsync async = UserService.App.getInstance();
        async.getUserById(user_id,new Callback<User>() {
            @Override
            public void doResult(User result) {
                login = new Label(result.getLogin());            
            }
        });
        panel.add(login);
        panel.add(image);
        this.initWidget(panel);
    }

    public Image getImage() {
        return image;
    }

    public Label getLogin() {
        return login;
    }
}
